package com.smart.car.member.feign;

import com.smart.car.common.res.bean.ResponseResult;
import com.smart.car.common.res.entity.PointsInfo;
import com.smart.car.common.res.exception.BusinessException;
import com.smart.car.member.feign.fallback.PointsServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * TODO points积分类的feignService接口(feign客户端)
 * TODO 显示声明这个接口用来远程调用study服务的接口。
 * TODO value 属性表示作用到哪个微服务上，fallback指定失败的回退处理，改为Sentinel的fallback处理。
 * @author: zoutao
 * @date: 2021/4/24
 */
@FeignClient(value = "smartcar-points")
//@FeignClient(value = "smartcar-points",fallback = PointsServiceFallback.class)
public interface PointsFeignService {

    // 业务类直接调用该接口即可
    @PostMapping(value = "/points/addCard")
    public ResponseResult<Integer> addPoints(@RequestParam(value = "json") String json) throws BusinessException;

    @PostMapping(value = "/points/updateCard")
    public ResponseResult<Integer> updateCard(@RequestParam(value = "json") String json) throws BusinessException;

    /**
     * 声明式接口,远程调用
     * 业务类直接调用该接口即可，若服务不可用，则触发PointsServiceFallback兜底方法。
     */
    @GetMapping("points/info/{id}")
    public ResponseResult getUserPoints(@PathVariable("id") String id);

    // 远程调用方法，指定远程调用的方法的路径
    @GetMapping("member/{pointsId}")
    public ResponseResult getPointsById(@PathVariable("pointsId") String pointsId);

    // 远程调用方法，指定远程调用的方法的路径
    @PostMapping("member/findPoint")
    public ResponseResult getPointsByPhone(@PathVariable("phone") String phone);

    @PostMapping(value = "/points/getData")
    public ResponseResult<PointsInfo> getData(@RequestParam(value = "memberId") String memberId);



}